/**
 * copyright (c) by handpay 2013
 */
package com.handpay.framework.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

import com.handpay.zztong.hp.R;

/**
 * 数字键盘
 * 
 * @author：Klaus Liu E-mail: lpluck08@gmail.com
 * @date：2013-3-21 下午02:37:14
 */
public class HPNumberKeyboard extends HPKeyBoard implements
		View.OnClickListener {
	private OnClickButtonLinster	clickButtonLinster;
	private Button btnOK;

	private static final int[]		idButtonNumbers	= new int[] {
			R.id.hpKbNum0, R.id.hpKbNum1, R.id.hpKbNum2, R.id.hpKbNum3,
			R.id.hpKbNum4, R.id.hpKbNum5, R.id.hpKbNum6, R.id.hpKbNum7,
			R.id.hpKbNum8, R.id.hpKbNum9, R.id.hpKbOk };

	public HPNumberKeyboard(Context context, AttributeSet attrs) {
		super(context, attrs);
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater = LayoutInflater.from(context);
		inflater.inflate(R.layout.hp_number_keyboard, this);

		for (int i = 0; i < idButtonNumbers.length; i++) {
			findViewById(idButtonNumbers[i])
					.setOnClickListener(this);
		}
		btnOK = (Button) findViewById(idButtonNumbers[idButtonNumbers.length - 1]);
		findViewById(R.id.hpKbDelete).setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
        int id = v.getId();
		if(id == R.id.hpKbDelete) {
            this.clickButtonLinster.onClickDelete();
        } else if(id == R.id.hpKbOk) {
            this.clickButtonLinster.onClickOK();
        } else {
			this.clickButtonLinster.onClickNumButton(((Button) v).getText()
					.toString());
		}
	}

	public void setClickButtonLinster(OnClickButtonLinster clickButtonLinster) {
		this.clickButtonLinster = clickButtonLinster;
	}
	
	/**
	 * 修改确认键文字
	 * 
	 * @param text
	 */
	public void setOKButtonText(String text)
	{
		btnOK.setText(text);
	}
}
